<?php
/**
 * 商品活动
 * User: yuanxuncheng
 * Date: 2016-12-21
 * Time: 22:39
 */

namespace app\api\model\dao;

use think\Model;
use think\Db;

class GoodsActivity extends Model
{
    //set talbename
    protected $table = 'goods_activity';
    //set primary key
    protected $pk = 'act_id';

    /**
     * @desc 增加商品活动
     * @param $param
     * @return false|int
     */
    public function addGoodsActivity($param)
    {
        $this->allowField(true)->save($param);
        return $this->data[$this->pk];
    }

    /**
     * @desc 获取商品活动
     * @param $act_id
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function getGoodsActivity($act_id)
    {
        $conds = array(
            'act_id' => $act_id,
        );
        $field = '*';
        return Db::table($this->table)->where($conds)->field($field)->select();
    }
}
